package com.xuzhijie.pms.controller;


import cn.hutool.core.bean.BeanUtil;
import com.xuzhijie.pms.common.Result;
import com.xuzhijie.pms.entity.MoveRequest;
import com.xuzhijie.pms.entity.Pet;
import com.xuzhijie.pms.entity.Property;
import com.xuzhijie.pms.entity.dto.PetDto;
import com.xuzhijie.pms.entity.vo.PetVo;
import com.xuzhijie.pms.entity.vo.PropertyVo;
import com.xuzhijie.pms.service.IPetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 许志杰
 * @since 2024-02-16
 */
@RestController
@RequestMapping("/pet")
public class PetController {

    @Autowired
    private IPetService service;

    @GetMapping("/page")
    public Result findPage(@RequestParam Integer page,
                           @RequestParam Integer size,
                           @RequestParam Integer gender,
                           @RequestParam Integer isCheckIn,
                           @RequestParam Integer isLogOut,
                           @RequestParam String color,
                           @RequestParam String variety) {

        return service.findPage(page, size,gender,isCheckIn,isLogOut,variety,color);
    }

    @PutMapping("/unbinding")
    public Result unbindingPet(@RequestBody String id){
        return service.unbindingPet(id);
    }

    @PostMapping("/create")
    public Result createPet(@RequestBody PetDto petDto){
        return service.createPet(petDto);
    }

    @GetMapping("/petByid")
    public Result feedbackInfoById(@RequestParam String id){
        Pet byId = service.getById(id);

        return Result.success(byId);
    }

    @GetMapping("/wx-getByOwnerId")
    public Result getByOwnerId(@RequestParam String id){
        return service.getByOwnerId(id);
    }

    @GetMapping("/wx-getPetById")
    public Result WxGetPetById(@RequestParam String id){
        Pet byId = service.getById(id);
        PetVo petVo = new PetVo(byId);
        BeanUtil.copyProperties(byId,petVo);
        return Result.success(petVo);
    }
}

